<?php

use app\common\services\StaticServices;
use yii\helpers\Url;

?>

<?= Yii::$app->view->renderFile('@app/modules/admin/views/common/tab_member.php', ['tab' => 'exchange']) ?>
<div class="ui equal width grid">
  <div class="column">
    <div class="panel">
      <div class="panel-alone-content">
        <form class="ui form">
          <div class="field">
            <label>会员名称:</label>
            <input type="text" name="member-name" placeholder="不能少于3个字"
                   value="<?= isset($info['member_name']) ? $info['member_name'] : '' ?>" disabled>
          </div>
          <div class="field">
            <label>会员电话:</label>
            <input type="text" name="member-phone" placeholder=""
                   value="<?= isset($info['member_phone']) ? $info['member_phone'] : '' ?>" disabled>
          </div>
          <div class="field">
            <label>商品:</label>
            <div class="ui selection dropdown _dropdown" tabindex="0">
              <input type="hidden" name="exchange-good" value="">
              <i class="dropdown icon"></i>
              <div class="default text"> 请选择商品</div>
              <div class="menu transition hidden" tabindex="-1">
                <?php foreach (StaticServices::getGoods($info['id']) as $item): ?>
                  <div class="item" data-value="<?= $item['id'] ?>"><?= $item['good_name'] ?></div>
                <?php endforeach; ?>
              </div>
            </div>
          </div>

          <input type="hidden" name="_csrf" id='csrf' value="<?= Yii::$app->request->csrfToken ?>">
          <input type="hidden" name="member-id" value="<?= isset($info['id']) ? $info['id'] : 0 ?>">
          <input type="hidden" name="get-goods" value="<?= count(StaticServices::getGoods($info['id'])) ?>">
          <button class="ui green basic button member-exchange  " type="button">兑换商品</button>
        </form>
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
  require(['modules/member/exchange'], function (exchange) {
    exchange.member_down("dropdown");
    exchange.member_exchange()
  });
</script>